pub fn check_dependencies(pkg_type: PackageType) -> Result<(), String> {
    match pkg_type {
        PackageType::Flatpak => {
            if !command_exists("flatpak") {
                return Err("未安装 Flatpak 运行时，请运行：\nsudo apt install flatpak".into());
            }
        }
        PackageType::Snap => {
            if !command_exists("snap") {
                return Err("未安装 Snapd 服务，请运行：\nsudo apt install snapd".into());
            }
        }
        _ => {}
    }
    Ok(())
}

fn command_exists(cmd: &str) -> bool {
    let output = std::process::Command::new("which")
        .arg(cmd)
        .output()
        .unwrap_or_default();
    output.status.success()
}